//****************************************************************/
//Creation History
// Company: GZ office
// NAME:    SysParamServlet.java
// TITLE:   System parameter 
// BY:      Oscar Bai
// DATE:    2003-03-04
//******************************************************************/
//Modification History
//******************************************************************/
//******************************************************************/


package admin.system.sysparam;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.servlet.*;
import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;
import com.ffpc.util.*;

public class SysParamServlet
  extends DBServlet {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      String action = new String(request.getParameter("formAction"));
      SysParamBean sysParam = SysParamProcess.createBean();
      sysParam.setSys_Param_name(request.getParameter("sys_param_name"));
      sysParam.setSys_Param_value(request.getParameter("sys_param_value"));
      sysParam.setSys_Param_des(request.getParameter("sys_param_des"));

      sysParam.setUpd_user(getUser().getUser_id());
      sysParam.setUpd_date(DateFormatter.format(this.getDate()));

      if (action.trim().equalsIgnoreCase("Create"))
      {
         sysParam.setCrt_user(getUser().getUser_id());
         sysParam.setCrt_date(DateFormatter.format(this.getDate()));

        if (SysParamProcess.insert(this.getConnection(),sysParam)>0)
            message.setMessage("Save successfully.");
        else
            message.setMessage("Save failure");
      }
      else if (action.trim().equalsIgnoreCase("Update"))
        if (SysParamProcess.update(this.getConnection(),sysParam)>0)
            message.setMessage("Save successfully.");
        else
            message.setMessage("Save failure.");
      else if (action.trim().equalsIgnoreCase("Delete"))
        if (SysParamProcess.delete(this.getConnection(),sysParam)>0)
            message.setMessage("Delete successfully.");
        else
            message.setMessage("Delete failure.");
      else
            message.setMessage("No action mapped!");
      return "system/SysParamSearch.jsp";
  }
}


